﻿using MediatR;
using System.WXT.Infrstructre.Interface;
using System.WXT.WebAPI.Application.Command.WorkerHourCommand;

namespace System.WXT.WebAPI.Application.CommandHandlers.WorkeHourCommandHandlers
{
    public class WorkeHourDeleteCommandHandlers:IRequestHandler<WorkerHourDeleteCommand,int>
    {
        protected readonly IWorkerHourRepository workerHourRepository;

        public WorkeHourDeleteCommandHandlers(IWorkerHourRepository workerHourRepository)
        {
            this.workerHourRepository = workerHourRepository;
        }
        /// <summary>
        /// 工人工时删除
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task<int> Handle(WorkerHourDeleteCommand request, CancellationToken cancellationToken)
        {
            var list = await workerHourRepository.GetBaby(request.workerHourId);
            list.workerHourIsDel = 1;
            return await workerHourRepository.Update(list);
        }
    }
}
